/*
 * Created on 07.12.2003
 */
package observations;

import java.util.*;

/**
 <code>Observation</code> Represents something like '10.10.04 bloodpressure
 * high'. It's part of Fowler's 'Observation'-pattern. Observation links the
 * object (patient) to a phenomenon.
 
 @author Sascha Hemminger
 @version 1.0 2004-09-10
 @see observations.Phenomenon
 @see observations.Patient
 */
public class Observation extends DomainObject {

  private boolean isPresent;

  protected Phenomenon phenomenon;

  private Date whenObserved;

  /**
   * Default constructor for Observation.
   */
  public Observation() {
  }

  /**
   * Constructs an Observation object.
   
   @param relevantPhenomenon
   *            observed phenomenon
   @param isPresent
   *            true if observation is valid at the moment
   @param patient
   *            patient observed
   @param whenObserved
   *            when did you make the observation
   */
  public Observation(Phenomenon relevantPhenomenon, boolean isPresent,
      Patient patient, Date whenObserved) {
    phenomenon = relevantPhenomenon;
    this.isPresent = isPresent;
    patient.observationsAdd(this);
    this.whenObserved = whenObserved;
  }

  /**
   * Gives a valuation in quality for the observation.
   
   @return the phenomenon observed e.g. 'high'
   */
  public Phenomenon getPhenomenon() {
    return phenomenon;
  }

  /**
   * Gives the observations type.
   
   @return the type of the observed phenomenon e.g. 'bloodpressure'
   */
  public PhenomenonType getPhenomenonType() {
    return phenomenon.getPhenomenonType();
  }

  protected void initialize(Patient patient, Date whenObserved) {
    patient.observationsAdd(this);
    this.whenObserved = whenObserved;
  }

  /**
   * Gives information whether the observation is the latest one.
   
   @return true if observation is still valid else false
   */
  public boolean isPresent() {
    return isPresent;
  }

  /**
   * Gives the date when observed.
   
   @return when the phenomenon was observed
   */
  public Date whenObserved() {
    return whenObserved;
  }

}